package com.healthbox.notifications.controller;


import com.healthbox.notifications.commom.Result;
import com.healthbox.notifications.entity.HealthState;
import com.healthbox.notifications.service.HealthStateService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chs
 * @since 2022-05-12
 */
@RestController
@Api(tags = "健康信息系统")
@RequestMapping("/healthstate")
public class HealthStateController {

    @Autowired
    HealthStateService healthStateService;

    @ApiOperation(value = "查看健康状态",notes = "用户可以查看健康状态")
    @ApiResponses({ @ApiResponse(code = 200, message = "操作成功",response = HealthState.class ) })
    @ApiImplicitParam(name = "phoneNum", value = "用户手机号（账号）", type = "Long", paramType = "query")
    @GetMapping("/get")
    public Result getHealthState(@RequestHeader("user-phone") String phone){

        return healthStateService.getHealthState(phone);
    }

    @ApiOperation(value = "变更当前所在地",notes = "用户可以变更当前所在地")
    @ApiResponses({ @ApiResponse(code = 200, message = "操作成功",response = HealthState.class ) })
    @PutMapping("/update")
    public Result updateHealthState(@RequestBody HealthState healthState,
                                    @RequestHeader("user-phone") String phone){

        return healthStateService.updateHealthState(healthState,phone);
    }



}
